From 47221e98189daa34e47934d44223db12db84c7b9 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 6 Mar 2017 11:40:39 -0600 Subject: [PATCH] Use time crate directly to get the year --- Cargo.lock | 12 +----------- Cargo.toml | 2 +- src/cargo/lib.rs | 2 +- src/cargo/ops/cargo_new.rs | 4 ++-- tests/new.rs | 6 +++--- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7ef7624f..50266e140 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,6 @@ dependencies = [ "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cargotest 0.1.0", - "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", "crates-io 0.7.0", "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -37,6 +36,7 @@ dependencies = [ "tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -105,15 +105,6 @@ name = "cfg-if" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "chrono" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cmake" version = "0.1.20" @@ -850,7 +841,6 @@ dependencies = [ "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" -"checksum chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00" "checksum cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a6805df695087e7c1bcd9a82e03ad6fb864c8e67ac41b1348229ce5b7f0407" "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" "checksum curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c90e1240ef340dd4027ade439e5c7c2064dd9dc652682117bd50d1486a3add7b" diff --git a/Cargo.toml b/Cargo.toml index 922575872..bed515a48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ name = "cargo" path = "src/cargo/lib.rs" [dependencies] -chrono = "0.2.25" crates-io = { path = "src/crates-io", version = "0.7" } crossbeam = "0.2" curl = "0.4.6" @@ -44,6 +43,7 @@ shell-escape = "0.1" tar = { version = "0.4", default-features = false } tempdir = "0.3" term = "0.4.4" +time = "0.1.36" toml = "0.3" url = "1.1" diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index fe11b4e7e..0d4d072fc 100755 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -5,7 +5,6 @@ #[macro_use] extern crate log; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; -extern crate chrono; extern crate crates_io as registry; extern crate crossbeam; extern crate curl; @@ -27,6 +26,7 @@ extern crate shell_escape; extern crate tar; extern crate tempdir; extern crate term; +extern crate time; extern crate toml; extern crate url; diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index f5950964a..6f6a7b672 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -8,9 +8,9 @@ use git2::Config as GitConfig; use term::color::BLACK; -use chrono::{Datelike,Local}; use handlebars::{Handlebars, no_escape}; use tempdir::TempDir; +use time; use toml; use core::Workspace; @@ -521,7 +521,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> { let mut data = BTreeMap::new(); data.insert("name".to_owned(), name.to_owned()); data.insert("author".to_owned(), author); - data.insert("year".to_owned(), Local::now().year().to_string()); + data.insert("year".to_owned(), (time::now().tm_year + 1900).to_string()); let template_set = try!(get_input_template(config, opts)); for template in template_set.template_files.iter() { diff --git a/tests/new.rs b/tests/new.rs index 9ddedc420..7a4532520 100644 --- a/tests/new.rs +++ b/tests/new.rs @@ -1,8 +1,8 @@ extern crate cargo; extern crate cargotest; -extern crate chrono; extern crate hamcrest; extern crate tempdir; +extern crate time; use std::fs::{self, File}; use std::io::prelude::*; @@ -11,7 +11,6 @@ use std::env; use cargo::util::ProcessBuilder; use cargotest::process; use cargotest::support::{execs, git, paths}; -use chrono::{Datelike,Local}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; use tempdir::TempDir; @@ -95,7 +94,8 @@ fn main () { let license = paths::root().join("foo/LICENSE"); let mut contents = String::new(); File::open(&license).unwrap().read_to_string(&mut contents).unwrap(); - assert!(contents.contains(&format!("(c) {} {}", Local::now().year(), "foo"))); + let expected = format!("(c) {} {}", (time::now().tm_year + 1900).to_string(), "foo"); + assert!(contents.contains(&expected)); assert_that(cargo_process("build").cwd(&paths::root().join("foo")), execs().with_status(0)); -- 2.30.2